﻿@using KRM.Core

@model Cancellation
@{
    ViewBag.Title = "Cancel Order Item";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    var enable = (!Model.Cancelled && !Model.OnHold);
}

<div style="padding: 10px">
    @Html.Partial("Partial/_MessageResult")
    <div class=" border-padding10">
        <form action="/orderview/cancelorderitem" method="POST" id="fr-cancelorder" class="margin0">
            <input type="hidden" name="actioncancel" id="hfactioncancel" value="1" />
            <input type="hidden" name="OrderItemId" value="@ViewBag.OrderItemId" />
            <div id="warehouse" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="warehouse" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h5 id="myModalLabel">Select warehouse</h5>
                </div>
                <div class="modal-body">
                    <div class="text-center">
                        @Html.DropDownList("Warehouseid")
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary ">Ok</button>
                </div>
            </div>
            <!-- /.modal -->
            <a href="#warehouse" role="button" data-toggle="modal" id="choosewarehouse"></a>
            <div class="row-fluid">
                <div class="span10">
                    <div class="row-fluid">
                        <div class="span4">Item</div>
                        <div class="span8">@Model.ProductName</div>
                    </div>
                    <div class="row-fluid">
                        <div class="span4">Reason</div>
                        <div class="span8">
                            @(enable ? Html.DropDownList("CancellationReasonID", null, new { @class = "input-block-level" }) : Html.DropDownList("CancellationReasonID", null, new { @class = "input-block-level", disabled = "disabled" }))
                            
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span4">Action</div>
                        <div class="span8">
                            @(enable ? Html.DropDownList("ActionID", null, new {@class = "input-block-level"}) : Html.DropDownList("ActionID", null, new {@class = "input-block-level", disabled = "disabled"}))
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span4">Reason</div>
                        <div class="span8">
                            <textarea name="Reason" class="input-block-level txt-reasoncancel" required="required" rows="4" @(!enable ? "disabled=disabled" : "")></textarea>
                        </div>
                    </div>
                </div>
                <div class="span2">
                    
                    @if (!Model.Cancelled)
                    {
                        <input type="button" class="btn btn-danger btn-CancelledItemFirst" value="Cancelled" style="width: 100px; margin-top: 10px" onclick="cancelorderitem();" />
                        <input type="submit" class="btn btn-danger btn-CancelledItem" style="display: none;" />
                    }
                    else
                    {
                        <input type="button" class="btn btn-success btn-UnCancelledItem" value="UnCancelled" style="width: 100px" />
                    }
                    <input type="button" onclick="javascript: window.close();" class="btn btn" value="Close" style="width: 100px; margin-top: 10px" />
                </div>
            </div>
        </form>
    </div>
    <fieldset>
        <legend>History</legend>
        <table class="table table-bordered table-fix">
            <thead>
                <tr>
                    <th>HistoryType</th>
                    <th>HistoryDate</th>
                    <th>UserName</th>
                    <th>ReasonForChange</th>
                    <th>OrderItemId</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.ListHistories)
                {
                    <tr>
                        <td>@item.HistoryType</td>
                        <td>@item.HistoryDate</td>
                        <td>@item.UserName</td>
                        <td>@item.ReasonForChange</td>
                        <td>@item.orderitemid</td>
                    </tr>
                }
            </tbody>
        </table>
    </fieldset>
</div>
